//
//  ReportDetailViewController.m
//  HarmonizePub
//
//  Created by Haven on 16/9/30.
//  Copyright © 2016年 Zy. All rights reserved.
//

#import "ReportDetailViewController.h"
#import "Config.h"
#import "URLTool.h"

@interface ReportDetailViewController ()
@property (nonatomic, strong) UIWebView *webView;

@end

@implementation ReportDetailViewController
// 懒加载webView
- (UIWebView *)webView
{
    if (_webView == nil) {
        _webView = [[UIWebView alloc] init];
    }
    return _webView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = self.name;

   // 初始化webView
    [self setupWebView];
    
}

// 加载webView
- (void)setupWebView
{
    NSString *token = [UserDefaultsTool stringForKey:XHToken];
    
    self.view.backgroundColor = [UIColor lightGrayColor];
    
    self.webView.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height - 64);
    
    [self.view addSubview:_webView];
    
    NSURL *url = nil;
    
    // 拼接url
    if (self.type) { // 检验报告
        url = [URLTool webURLStringWithPathString:[NSString stringWithFormat:@"%@?num=%@", XHJybgmx, self.Id] token:token];
    }else{ // 检查报告
        url = [URLTool webURLStringWithPathString:[NSString stringWithFormat:@"%@?checkId=%@", XHJcbgmx, self.Id] token:token];
    }
    
    XHLog(@"%@", url);
    NSURLRequest *request = [NSURLRequest requestWithURL: url];
    
    [_webView loadRequest:request];
}
@end
